#ifndef		___DATA_SESSION_IMP___
#define		___DATA_SESSION_IMP___


#include "Message/MsgBuffer.h"

class DataService;

class DataSession
{
public:
	DataSession(boost::asio::io_service &svcIO);

	int		getID()const;
	void	setID(int nID);

	bool read(MsgBuffer* pStream = NULL);
	bool write(MsgBuffer* pStream);

	virtual bool onUpdate(const int& nElapse);

	void onInput(const boost::system::error_code& error, MsgBuffer* pStream );
	void onOutput(const boost::system::error_code& error, MsgBuffer* pStream );

	boost::asio::ip::tcp::socket& getSocket();

	void	setDataStreamPool(MsgBufferFactory* pMsgBuffFact);
private:
	int	m_nSesId;

	boost::asio::ip::tcp::socket	m_theSocket;
	boost::asio::io_service&		m_theSvcIO;

	MsgBufferFactory*			m_wpMsgBufferFactory;
};

typedef stdext::hash_map<int, DataSession*>	DataSessionMap;

#endif